package com.biglead.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.biglead.demo.mapper.SecKillOrderMapper;
import com.biglead.demo.pojo.SeckillOrder;
import com.biglead.demo.service.SecKillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SecKillOrderServiceImpl implements SecKillOrderService {

    @Autowired
    private SecKillOrderMapper secKillOrderMapper;

    @Override
    public SeckillOrder findSecKillOrder(Long goodsId, Long userId) {
        QueryWrapper<SeckillOrder> wrapper = new QueryWrapper<>();
        wrapper.eq("goods_id", goodsId)
                .eq("user_id", userId);
        return secKillOrderMapper.selectOne(wrapper);
    }

    @Override
    public int save(SeckillOrder seckillOrder) {
        return secKillOrderMapper.insert(seckillOrder);
    }

}
